package cn.zs.supply.common.core.domain.query;

import lombok.Data;

import java.io.Serializable;
@Data
public class PageQuery extends Query implements Serializable {
    private static final long serialVersionUID = 4064021875470100132L;
    private Integer pageNo = 1;

    private Integer pageSize = 10;

    private Integer startRowNo = (pageNo - 1) * pageSize;

    public PageQuery() {
    }

    public PageQuery(Integer pageNo, Integer pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    /**
     * 查询一行，用于查找唯一匹配的数据
     */
    public void one() {
        this.pageNo = 1;
        this.pageSize = 1;
    }

    public void setPageNum(int pageNum){
        this.pageNo = pageNum;
    }

    public int getPageNum(){
        return this.pageNo;
    }

    /**
     * 当前页的第一条记录
     */
    public int getStartRowNo() {
        return (this.pageNo - 1) * this.pageSize;
    }

    @Override
    public String toString() {
        return "PageQuery{" +
                "pageNo=" + pageNo +
                ", pageSize=" + pageSize +
                '}';
    }
}

